from redis import StrictRedis
def get_redis(config):

    redis = StrictRedis(host=config["host"], port=config["port"], db=config["db"], password=config["password"],
                        retry_on_timeout=True)
    retry = 0
    while(retry<20):
        try:
            redis.get(f"lock_record")
            print("redis connect success：" + str(retry))
            retry = 20
        except:
            retry = retry + 1
            print("redis reconnect times："+str(retry))
            redis = StrictRedis(host=config["host"], port=config["port"], db=config["db"], password=config["password"],
                                retry_on_timeout=True)
    return redis